<include file="Common:minheader" />
<form class="layui-form" action="" id="cheform" >
    <input type="hidden" name="id" value="{$info.id}">
	<div class="layui-form-item">
		<label class="layui-form-label">所属场馆</label>
		<div class="layui-input-block">
			<select name="store_id" lay-verify="required">
				<option value="">请选择</option>
				<notempty name="storeList">
					<volist name="storeList" id="vo" key="key">
						<option value="{$vo.id}" <if condition="$vo['id'] eq $info['store_id']">selected</if>>{$vo.title}</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">头像</label>
		<div class="layui-input-block">
			<div class="layui-upload">
			  <button type="button" class="layui-btn" id="test2">上传图片</button>
			  <div class="layui-upload-list" id="demo2" data-id="">
				<if condition="!empty($info['avatarurl'])">
					<div class="imgcss"><input type="hidden" name="avatarurl" id="smallimage1" value="{$info.avatarurl}"><a href="{$info.avatarurl}" target="_blank"><img src="{$info.avatarurl}" width="150"></a></div>
				</if>
			  </div>
			  <div id="demoText1"></div>
			</div> 
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label" style="width:auto">用户名</label>
		<div class="layui-input-block">
			<input value="{$info.username}" type="text" name="username" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label" style="width:auto">手机号</label>
		<div class="layui-input-block">
			<input value="{$info.mobile}" type="text" name="mobile" required  lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">来源</label>
		<div class="layui-input-block">
			<select name="source" lay-verify="required">
				<option value="">请选择</option>
				<notempty name="sourceList">
					<volist name="sourceList" id="vo" key="key">
						<option value="{$vo.value}" <if condition="$vo['value'] eq $info['source']">selected</if>>{$vo.name}</option>
					</volist>
				</notempty>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
		  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
		  <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>
<script>
	layui.use('upload', function(){
    	var $ = layui.jquery
    	,upload = layui.upload;
    	var uploadInst = upload.render({
    		elem: '#test2'
    		,url: "{:U('Common/uploadImage')}"
    		,size:'0'
    		,exts:'jpeg|gif|png|jpg'
    		,multiple: false
    		,method: 'POST'
    		,before: function(obj){
    			//预读本地文件示例，不支持ie8
    			obj.preview(function(index, file, result){
    				$('#demo2').html('<div class="imgcss"><input type="hidden" name="avatarurl" id="smallimage1"><img src="'+result+'" width="150"></div>'); //文件名
    			});
    		}
    		,done: function(res){
    			//如果上传失败
    			if(res.code==0){
    				return layer.msg(res.value);
    			}else{
    				$('#smallimage1').val(res.value);
    			}
    		}
    		,error: function(){
    			//演示失败状态，并实现重传
    			var demoText = $('#demoText1');
    			demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
    			demoText.find('.demo-reload').on('click', function(){
    				uploadInst.upload();
    			});
    		}
    	});
    });
	layui.use('form', function(){
		var form = layui.form;
		form.on('submit(formDemo)', function(data){
			var cont = $('#cheform').serialize();
			$.ajax({
				url:"{:U('Users/editVip')}",
				type:'post',
				dataType:'json',
				data:cont,
				success:function(data){
					if(data.code==0){
						layer.alert(data.message);
					}else{
						layer.alert(data.message, function(index){
							//do something
							window.location.href="{:U('Users/vipList')}";
						});
					}
				}
			});
			//layer.msg(JSON.stringify(data.field));
			return false;
		});
	});
</script>
 <!-- /. PAGE INNER  -->
<include file="Common:footer" />
    